package sjtu.pirate.format;

import java.net.URI;
import java.util.List;

public class Form {
	private String name;
	private URI uri;
	private FormMethod method;
	private URI actionURI;
	private List<Input>inputList;
	
	public enum FormMethod {
		GET("GET"),
		POST("POST");
		private String value;
		private FormMethod(String s) {
			value = s;
		}
		public String toString() {
			return value;
		}
	}
	
	public Form(String name, URI uri, FormMethod method, URI actionURI, List<Input> inputList) {
		this.name = name;
		this.method = method;
		this.inputList = inputList;
		setURIs(uri, actionURI);
	}

	public void setURIs(URI uri, URI actionURI) {
		this.uri = uri;
		this.actionURI = uri.resolve(actionURI);
	}
	
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public URI getURI() {
		return uri;
	}
	public void setURI(URI uri) {
		this.uri = uri;
	}
	public URI getActionURI() {
		return actionURI;
	}
	public void setActionURI(URI actionURI) {
		this.actionURI = actionURI;
	}
	public FormMethod getMethod() {
		return method;
	}
	public void setMethod(FormMethod method) {
		this.method = method;
	}
	public List<Input> getInputList() {
		return inputList;
	}
	public void setInputList(List<Input> inputList) {
		this.inputList = inputList;
	}
}
